
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import jpcap.JpcapCaptor;
import jpcap.NetworkInterface;
public class ARP
{
    NetworkInterface[] devices;
    /**
     * Constructor
     */
    public ARP()
    {
       devices = JpcapCaptor.getDeviceList();
    }
    /**
     * gives back the network devices.
     */
    public void networkDevices()
    {

        for( int i = 0 ; i < devices.length; i++)
        {
            System.out.println(" datalink:"+" "+devices[i].name +" "
                + "Description:"+ " " +devices[i].description);
        }
    }
    /**
     * returns the MAC address.
     * Not sure if its correct as of now the MAC address do not correspond
     * to what my router says.
     */
    public void MACaddress()
    {
        for( int i = 0 ; i < devices.length; i++)
        {
            System.out.print(" MAC address:");
            for (byte b : devices[i].mac_address)
            {
                System.out.print(Integer.toHexString(b&0xff) + ":");
                
            }
            System.out.println();
        }
     
    }
    
    public void getTheStuff() throws IOException
    {
        NetworkInterface[] capture = JpcapCaptor.getDeviceList();
        //Open an interface with openDevice(NetworkInterface intrface, int snaplen, boolean promics, int to_ms)
        JpcapCaptor captor=JpcapCaptor.openDevice(capture[2], 65535, true, 20);
        PacketStorage ps = new PacketStorage();
        captor.loopPacket( 600, ps );
        
        
    }
   
}
